# Maintainer: Rexct < rexct1 at gmail dot com >
# Contributor: BartU+0142omiej Piotrowski <nospam@bpiotrowski.pl>
# Contributor: Andreas Radke <andyrtr@archlinux.org>
# Contributor: judd <jvinet@zeroflux.org>

pkgname=vsftpd
pkgver=3.0.2
pkgrel=2
pkgdesc="Very Secure FTP daemon"
arch=('sh4')
url="https://security.appspot.com/vsftpd.html"
license=('GPL2')
depends=('openssl')
backup=('etc/vsftpd.conf' 'etc/xinetd.d/vsftpd')
install=vsftpd.install
source=(https://security.appspot.com/downloads/$pkgname-$pkgver.tar.gz{,.asc}
        vsftpd.xinetd )
sha256sums=('be46f0e2c5528fe021fafc8dab1ecfea0c1f183063a06977f8537fcd0b195e56'
            'SKIP'
            '5078069720b058a12980942b4daa6d82a6d4f0cf298a2cd848270f150244da0b')

build() {
  cd $pkgname-$pkgver

  # build-time config
  sed \
    -e 's|^#undef VSF_BUILD_SSL$|#define VSF_BUILD_SSL|' \
    -i builddefs.h

  CFLAGS+=' -fPIE' LINK='' LDFLAGS="-fPIE -pie ${LDFLAGS} -Wl,-z,now" make
}

package() {
  cd $pkgname-$pkgver

  install -D -m755 vsftpd $pkgdir/usr/bin/vsftpd
  install -D -m644 vsftpd.conf $pkgdir/etc/vsftpd.conf
  install -D -m644 vsftpd.8 $pkgdir/usr/share/man/man8/vsftpd.8
  install -D -m644 vsftpd.conf.5 $pkgdir/usr/share/man/man5/vsftpd.conf.5
  install -D -m644 $srcdir/vsftpd.xinetd $pkgdir/etc/xinetd.d/vsftpd

#  install -D -m644 $srcdir/vsftpd.service $pkgdir/usr/lib/systemd/system/vsftpd.service
#  install -D -m644 $srcdir/vsftpd@.service $pkgdir/usr/lib/systemd/system/vsftpd@.service 
#  install -D -m644 $srcdir/vsftpd-ssl.service $pkgdir/usr/lib/systemd/system/vsftpd-ssl.service
#  install -D -m644 $srcdir/vsftpd-ssl@.service $pkgdir/usr/lib/systemd/system/vsftpd-ssl@.service
#  install -D -m644 $srcdir/vsftpd.socket $pkgdir/usr/lib/systemd/system/vsftpd.socket
#  install -D -m644 $srcdir/vsftpd-ssl.socket $pkgdir/usr/lib/systemd/system/vsftpd-ssl.socket

  install -d -m755 $pkgdir/usr/share/empty
}
